
import BaseUI from "../../framwork/BaseUI";
import Toast from "../../framwork/common/Toast";
import GameData from "../data/GameData";
import MonsterData from "../data/MonsterData";

const {ccclass, property} = cc._decorator;

@ccclass
export default class MonsterManager extends BaseUI {
    private static _instance: MonsterManager = null;
    public static getInstance(): MonsterManager {
        return MonsterManager._instance;
    }
    baseUI_onLoad(): void {
        MonsterManager._instance = this;
        this.initMonster();

    }
    monsterInfo = {
        MaxHp:0,
        Hp:0,
        atk:0,
        SD:0,
    }
    initMonster(){
        this.monsterInfo.MaxHp = Number(MonsterData.HP)*(1+GameData.cengshu/10);
        this.monsterInfo.Hp = Number(MonsterData.HP)*(1+GameData.cengshu/10);
        this.monsterInfo.atk = Number(MonsterData.ATK)*(1+GameData.cengshu/10);
        this.monsterInfo.SD = Number(MonsterData.SD);
    }

    


    BeingBeaten(atk:number){//被打
        this.monsterInfo.Hp -= atk;
        this.resetView();
        if(this.monsterInfo.Hp <= 0){
            Toast.show("怪死了");
            this.init();
        }
    }
    baseUI_onDestroy(): void {

    }
    onBtn_click(target: cc.Button, onBtn_name: string): number | void {

    }
    init_data(d: any): void {

    }

}
